package OperationSystem.day1205File;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;

public class 从文件输入字节流中读文本内容 {
    public static void main(String[] args) throws IOException {
       /* try (InputStream is = new FileInputStream("没有中文.txt")) {
            byte[] buffer = new byte[1024];

            int len = is.read(buffer);
            StringBuffer sb=new StringBuffer();
            for (int i=0;i<len;i++){
               sb.append((char) buffer[i]);
            }
            System.out.println(sb.toString());
        }*/

       try (InputStream is=new FileInputStream("有中文.txt")){
           byte[] buffer=new byte[1024];

           int len=is.read(buffer);
           String s=new String(buffer,0,len,"UTF-8");
           System.out.println(s);
       }
    }
}
